<!--
* @Author: ShallowInk
* @Date: 2021-07-27 23:03:42
* @Description: 修改用户权限
* @FilePath: \GoodsManagement\src\pages\components\AddUser.vue
-->
<template lang="">
  <n-form :model="model" :rules="rules">
    <n-form-item path="permission" label="权限角色">
      <n-input v-model:value="model.permission" :on-input="onChange"></n-input>
    </n-form-item>
  </n-form>
</template>
<script lang="ts">
import { ref } from "vue";
import { NForm, NFormItem, NInput } from "naive-ui";
import { useMessage } from "naive-ui";
export default {
  components: {
    NForm,
    NFormItem,
    NInput,
  },
  setup() {
      /* 获取input中的值 */
      const modelRef = ref({
      permission: null,
    });
    
    /* 限制输入不能为空 */
    const message = useMessage();
    const rules = {
      permission: [
        {
            required: true,
            validator (rule, value) {
              if (!value) {
                return new Error('需要输入权限内容')
              }
              return true
            },
            trigger: ['input', 'blur']
          },
      ],}
      /* 点击传输信息 */
      const onChange = () => {
        // console.log(modelRef.value["permission"])
        sessionStorage.setItem("changePermission", modelRef.value["permission"])
      }


    return {
      model: modelRef,
      rules,
      onChange,
    };
  },
};
</script>
<style lang=""></style>
